<?php
//----------------------------------------------------------------------------------------------------------
if (!$_GET['pass'] || $_GET['pass']!="trytoguess") exit("You have no permission to view this page");

    require_once('../config.inc.php');

    require_once($config['app_dir'] . '/classes/stockmailer.data.php');
	require_once($config['app_dir'] . '/includes/db.class.php');

	$sessionid = $_GET['session'];
	$mtype = $_GET['mtype'];
	$tradeid = $_GET['trade'];
	$sysid = $_GET['system'];
	$notSend=array();

    echo "<h2>Session - ".$sessionid." | trade - ".$tradeid." | system - ".$sysid."</h2>";


	class getMails extends objStockMailerModel {
		public $_db = false;

		public function __contruct(){
			$this->_db = objDataBase::GetInstance();

		}
	}

	$mails= new getMails();




	echo "<b>MessageType = 1 :</b><br>";
   	$StockMailerModel = new objStockMailerModel();
	$data_mail1 = $mails->_db->handler->getAll("SELECT UserID,StatusID FROM fa_mailer_mails WHERE MessageType=1 AND SessionID=".$sessionid);


   	$emails = $StockMailerModel->getEmailsArr(1, $tradeid, $sysid);
	echo "<b>total  - ".count($emails)."</b><br>";


	$cnt=0;
   	foreach($emails as $item) {
                  echo $item['id']." - ";
                  echo $item['email'];
				  if (in_array(array('UserID' => $item['id'],'StatusID' => 0), $data_mail1)) {
						echo " - OK";
						//.array_search(array('UserID' => $item['id']),$data_mail1);
					}
				  else {
				  	$notSend[$cnt]['id'] = $item['id'];
				  	$notSend[$cnt]['email'] = $item['email'];
				  	$cnt++;
				  }
				  echo "<br>";
    }

   	echo "<br><br><br>";

   	echo "<br><br><br><h2>NOT SENT LIST</h2><br><hr>";
    	foreach($notSend as $item1) {
     		echo $item1['email']."<br>";
    	}

   	 echo "<hr><br><br><br>";
   	 echo "<br><br><br>";



   	echo "<b>MessageType = 4 :</b><br>";
   	$StockMailerModel1 = new objStockMailerModel();
	$data_mail4 = $mails->_db->handler->getAll("SELECT UserID FROM fa_mailer_mails WHERE MessageType=4 AND SessionID=".$sessionid);
   	$emails1 = $StockMailerModel1->getEmailsArr(4, $tradeid, $sysid);
	echo "<b>total  - ".count($emails1)."</b><br>";

   	foreach($emails1 as $item) {
                  echo $item['id']." - ";
                  echo $item['email'];
				  if (in_array(array('UserID' => $item['id']), $data_mail4)) echo " - OK";
				  echo "<br>";
    }

   	echo "<br><br><br>";


   	echo "<b>MessageType = 3 (SMS email) :</b><br>";
   	$StockMailerModel1 = new objStockMailerModel();
	$data_mail3 = $mails->_db->handler->getAll("SELECT UserID FROM fa_mailer_mails WHERE MessageType=3 AND SessionID=".$sessionid);
   	$emails2 = $StockMailerModel->GetSMSEmailsArr(1, $tradeid, $sysid);
    echo "<b>total  - ".count($emails2)."</b><br>";

    foreach($emails2 as $item) {
                  echo $item['id']." - ";
                  echo $item['email'];
				  if (in_array(array('UserID' => $item['id']), $data_mail3)) echo " - OK";
				  echo "<br>";
    }

   	echo "<br><br><br>";


   	echo "<b>MessageType = 5 (SMS direct) :</b><br>";
   	$StockMailerModel1 = new objStockMailerModel();
	$data_mail5 = $mails->_db->handler->getAll("SELECT UserID FROM fa_mailer_mails WHERE MessageType=5 AND SessionID=".$sessionid);
   	$emails3 = $StockMailerModel->GetSMSDirectArr(1, $tradeid, $sysid);
    echo "<b>total  - ".count($emails3)."</b><br>";

    foreach($emails3 as $item) {
                  echo $item['id']." - ";
                  echo $item['email'];
				  if (in_array(array('UserID' => $item['id']), $data_mail5)) echo " - OK";
				  echo "<br>";
    }

   	//echo "<br><br><br>NOT SENT (".count($notSend).")<br>";

   		//foreach($notSend as $item1) {
                  //echo $item1['id'];
                  //echo $item1['email'];
				  //echo "<br>";
    	//}





?>
